package com.viphuli.app.tool.adapter;

import java.util.List;

import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import butterknife.Bind;
import butterknife.ButterKnife;

import com.offroader.utils.ViewUtils;
import com.viphuli.app.tool.R;
import com.viphuli.app.tool.bean.part.ArrangeViewStatistics;
import com.viphuli.app.tool.common.MyApp;

public class ArrangeMonthViewGirdAdapter extends BaseAdapter {

	//界面列表  
	private List<ArrangeViewStatistics> statisticsList;

	public ArrangeMonthViewGirdAdapter(List<ArrangeViewStatistics> statisticsList) {
		this.statisticsList = statisticsList;
	}

	@Override
	public int getCount() {
		return statisticsList.size();
	}

	@Override
	public Object getItem(int index) {
		return statisticsList.get(index);
	}

	@Override
	public long getItemId(int index) {
		return index;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		ViewHolder holder = null;

		if (convertView == null || convertView.getTag() == null) {
			convertView = ViewUtils.inflateView(MyApp.getInstance(), R.layout.frag_arrange_month_view_girdview_item);
			holder = new ViewHolder(convertView);
			convertView.setTag(holder);

		} else {
			holder = (ViewHolder) convertView.getTag();
		}

		ArrangeViewStatistics statistics = statisticsList.get(position);

		holder.workText.setText(statistics.getArrangeType().getName());
		holder.workText.setTextColor(Color.parseColor(statistics.getArrangeType().getColor()));
		holder.descText.setText("本月共计" + statistics.getCount() + "次");

		return convertView;
	}

	protected class ViewHolder {

		@Bind(R.id.id_view_month_statistics_girdview_item_work)
		TextView workText;

		@Bind(R.id.id_view_month_statistics_girdview_item_desc)
		TextView descText;

		public ViewHolder(View view) {
			ButterKnife.bind(this, view);
		}
	}

}
